package graph.net.commands;

import graph.net.internal.HelpReference;

/*************************************************************
 * @author amahmood
 *
 ************************************************************/
public class HelpCommand implements ICommand
{

    /* ***********************************************************
     * @see mule.ps1.net.commands.ICommand#execute(java.lang.String[])
     ************************************************************/
    public String execute(String[] messageTokens)
    {
        if (messageTokens == null || messageTokens.length == 0)
            throw new IllegalArgumentException("Requirment parameters is null;");

        StringBuffer sb = new StringBuffer();

        if (messageTokens.length == 1)
        {

            sb.append("All commands:");
            for (CommandName aCommand : CommandName.values())
            {
                sb.append(aCommand.toString());
                sb.append(", ");
            }
        }
        else
        {
            sb.append(HelpReference.getInstance().getHelp(messageTokens[1]));
        }

        return sb.toString();
    }

}
